
 <style type="text/css">
            .confirm{
                position:absolute;
                bottom:30px;right:4%;
                z-index:99;
                height: 50px;
                width: 50px; 
                line-height:50px;
                font-size:15px;
                text-align:center;
                background-color:white;
                background:#1ABC9C;
                color:white;
                border:none;
                cursor:pointer;
                border-radius: 50%;
            }
            /*.search {position:absolute;width:400px;top:0;left:50%;padding:5px;margin-left:-200px;}*/
        </style>
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('Admin_id')}:</label>
        <div class="col-xs-12 col-sm-8">

            <select id="c-admin_id" data-rule="required" class="form-control selectpicker" name="row[admin_id]">
                {foreach name="adminlist" item="vo"}
                    <option value="{$vo['id']}" {in name="$row.admin_id" value="$vo['id']"}selected{/in}>{$vo['username']}</option>
                {/foreach}
            </select>

        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Cat_id')}:</label>
        <div class="col-xs-12 col-sm-8">

            <select id="c-cat_id" data-rule="required" class="form-control selectpicker" name="row[cat_id]">
                {foreach name="catlist" item="vo"}
                    <option value="{$vo['id']}" {in name="$row.cat_id" value="$vo['id']"}selected{/in}>{$vo['name']}</option>
                {/foreach}
            </select>

        </div>
    </div>


    <div class="form-group">
    <label for="c-avatar" class="control-label col-xs-12 col-sm-2">{:__('Bg_img')}:</label>
    <div class="col-xs-12 col-sm-8">
        <div class="input-group">
            <input id="c-avatar" data-rule="" class="form-control" size="50" name="row[bg_img]" type="text" value="{$row.bg_img}">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="plupload-avatar" class="btn btn-danger plupload" data-input-id="c-avatar" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-avatar"><i class="fa fa-upload"></i> 上传</button></span>
                    <span><button type="button" id="fachoose-avatar" class="btn btn-primary fachoose" data-input-id="c-avatar" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
                </div>
            <span class="msg-box n-right" for="c-avatar"></span>
            </div>
            <ul class="row list-inline plupload-preview" id="p-avatar"></ul>
        </div>
    </div>

    <div class="form-group">
    <label for="c-cover" class="control-label col-xs-12 col-sm-2">{:__('Cover')}:</label>
    <div class="col-xs-12 col-sm-8">
        <div class="input-group">
            <input id="c-cover" data-rule="" class="form-control" size="50" name="row[cover]" type="text" value="{$row.cover}">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="plupload-cover" class="btn btn-danger plupload" data-input-id="c-cover" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-cover"><i class="fa fa-upload"></i> 上传</button></span>
                    <span><button type="button" id="fachoose-cover" class="btn btn-primary fachoose" data-input-id="c-cover" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
                </div>
            <span class="msg-box n-right" for="c-cover"></span>
            </div>
            <ul class="row list-inline plupload-preview" id="p-cover"></ul>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Major')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-major" class="form-control" name="row[major]" type="text" value="{$row.major}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Business_time')}早:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-business_time_u" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" name="row[business_time_u]" type="text" value="{$row.business_time_u}">
        </div>
    </div>

     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Business_time')}晚:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-business_time_u" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" name="row[business_time_d]" type="text" value="{$row.business_time_d}">
        </div>
    </div>

     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Info')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea class='editor' id="c-info" name="row[info]">
                {$row.info}
            </textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-money" class="form-control" name="row[money]" type="text" value="{$row.money}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Point')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-point" class="form-control" name="row[point]" type="text" value="{$row.point}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Cash_withdrawal')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-cash_withdrawal" class="form-control" name="row[cash_withdrawal]" type="text" value="{$row.cash_withdrawal}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Fund password')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-fund_password" class="form-control" name="row[fund_password]" type="text" value="{$row.fund_password}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-phone" class="form-control" name="row[phone]" type="text" value="{$row.phone}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bank')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bank" class="form-control" name="row[bank]" type="text" value="{$row.bank}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bank_num')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bank_num" class="form-control" name="row[bank_num]" type="number" value="{$row.bank_num}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bank_sup')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bank_sup" class="form-control" name="row[bank_sup]" type="text" value="{$row.bank_sup}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bank_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bank_name" class="form-control" name="row[bank_name]" type="text" value="{$row.bank_name}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Order')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-order" class="form-control" name="row[order]" type="number" value="{$row.order}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Take_rate')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-take_rate" class="form-control" name="row[take_rate]" type="text" value="{$row.take_rate}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Pay_point_rate')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-pay_point_rate" class="form-control" name="row[pay_point_rate]" type="text" value="{$row.pay_point_rate}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Red_pack_rate')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-red_pack_rate" class="form-control" name="row[red_pack_rate]" type="text" value="{$row.red_pack_rate}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Discount')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-discount" class="form-control" name="row[discount]" type="text" value="{$row.discount}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Change_point_rate')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-change_point_rate" class="form-control" name="row[change_point_rate]" type="text" value="{$row.change_point_rate}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Rebate_cash')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-rebate_cash" class="form-control" name="row[rebate_cash]" type="text" value="{$row.rebate_cash}">
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>

    <div class="search">
            <div class="input-group">
                <input type="text" id="place" name="q" class="form-control" placeholder="输入地点" />
                <span class="input-group-btn">
                    <button type="button" name="search" id="search-btn" class="btn btn-success">
                        <i class="fa fa-search"></i>
                    </button>
                </span>
           </div>
    </div>
    <div class="confirm">确定</div>
    <input type="hidden" name="row[lat]" id='lat' value="{$row.lat}" />
    <input type="hidden" name="row[lng]" id='lng' value="{$row.lng}" />
    <input id="c-address" class="form-control" name="row[address]" type="hidden" value="{$row.address}">
    <div id="container" style="width: 80%;height: 500px;margin:10px auto  ;"></div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Is_top')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[is_top]', ['1'=>'是', '0'=>'否'], $row['is_top'])}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[status]', ['1'=>__('Normal'), '0'=>__('Hidden')], $row['status'])}
        </div>
    </div>
</form>
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&libraries=place"></script>
        <script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>

  <script type="text/javascript">
            $(function () {
                var map, marker, geocoder, infoWin, searchService, address = null;
                var init = function () {
                    var lat = "{$row.lat}";
                    var lng = "{$row.lng}";

                    if(lat == '' || lng == ''){lat = '{$lat}';lng = '{$lng}';}

                    var center = new qq.maps.LatLng(lat,lng);

                    map = new qq.maps.Map(document.getElementById('container'), {
                        center: center,
                        zoom: parseInt("{$scale}")
                    });
                    //初始化marker
                    initmarker(center);

                    //实例化信息窗口
                    infoWin = new qq.maps.InfoWindow({
                        map: map
                    });
                    geocoder = new qq.maps.Geocoder({
                        complete: function (result) {
                            infoWin.open();
                            address = result.detail.addressComponents.province +
                                    result.detail.addressComponents.city +
                                    result.detail.addressComponents.district;
                            if (result.detail.addressComponents.streetNumber == '') {
                                address += result.detail.addressComponents.street;
                            } else {
                                address += result.detail.addressComponents.streetNumber;
                            }
                            infoWin.setContent(address);
                            infoWin.setPosition(result.detail.location);
                        }
                    });
                    //显示当前marker的位置信息窗口
                    geocoder.getAddress(center);

                    var latlngBounds = new qq.maps.LatLngBounds();
                    //查询poi类信息
                    searchService = new qq.maps.SearchService({
                        complete: function (results) {
                            var pois = results.detail.pois;
                            for (var i = 0, l = pois.length; i < l; i++) {
                                var poi = pois[i];
                                latlngBounds.extend(poi.latLng);
                                initmarker(poi.latLng);
                                //显示当前marker的位置信息窗口
                                geocoder.getAddress(poi.latLng);
                            }
                            map.fitBounds(latlngBounds);
                        }
                    });
                    //实例化自动完成
                    var ap = new qq.maps.place.Autocomplete(document.getElementById('place'));
                    //添加监听事件
                    qq.maps.event.addListener(ap, "confirm", function (res) {
                        searchKeyword();
                    });
                };

                //实例化marker和监听拖拽结束事件
                var initmarker = function (latLng) {
                    marker = new qq.maps.Marker({
                        map: map,
                        position: latLng,
                        draggable: true,
                        title: '拖动图标选择位置'
                    });
                    //监听拖拽结束
                    qq.maps.event.addListener(marker, 'dragend', function (event) {
                        var latLng = event.latLng,
                                lat = latLng.getLat().toFixed(5),
                                lng = latLng.getLng().toFixed(5);
                        var latLng = new qq.maps.LatLng(lat, lng);
                        //调用获取位置方法
                        geocoder.getAddress(latLng);
                    });
                };
                var close = function (data) {
                    var index = parent.Layer.getFrameIndex(window.name);
                    var callback = parent.$("#layui-layer" + index).data("callback");
                    //再执行关闭
                    parent.Layer.close(index);
                    //再调用回传函数
                    if (typeof callback === 'function') {
                        callback.call(undefined, data);
                    }
                };

                //执行搜索方法
                var searchKeyword = function () {
                    searchService.clear();//先清除
                    marker.setMap(null);
                    infoWin.close();
                    var keyword = $("#place").val();
                    searchService.setLocation("{$location}");//设置默认检索范围（默认为全国），类型可以是坐标或指定的城市名称。
                    searchService.setPageIndex(0);//设置检索的特定页数。
                    searchService.setPageCapacity(1);//设置每页返回的结果数量。
                    searchService.search(keyword);//开始查询
                };
                
                //点击确定后执行回调赋值
                $(document).on('click', '.confirm', function () {
                    var as = marker.getPosition();
                    var x = as.getLat().toFixed(5);
                    var y = as.getLng().toFixed(5);
                    var zoom = map.getZoom();
                    var data = {lat: x, lng: y, zoom: zoom, address: address};
                    //赋值给input
                    $('#place').val(data.address);
                    $('#lat').val(data.lat);
                    $('#lng').val(data.lng);
                    $('#c-address').val(data.address);
                    console.log(data);
                    alert('商家地理位置设置成功');
                   // close(data);
                });

                //点击搜索按钮
               /* $(document).on('click', '#search-btn', function () {
                    if ($("#place").val() == '')
                        return;
                    searchKeyword();
                });
*/
                init();
            });
        </script>